Skip to main content
Version: 2.0

Android

How to add a new profile item

Create a new profile item

To create a new profile item, you need to create a class that implements the SettingItem interface.

class MyProfileItem : SettingItem {
override val id: String = "my_profile_item"
override val iconResId: Int = R.drawable.ic_my_profile_item
override val name: TextRes = TextRes.StringRes(R.string.my_profile_item)

override val interactionHandler: SettingInteractionHandler =
DefaultSettingInteractionHandler.forScreen { context ->
//launch your screen here
}

// or
override val interactionHandler: SettingInteractionHandler =
DefaultSettingInteractionHandler.Toggle(
isSelected = true
) { toggle ->
//handle toggle
}

suspend fun shouldBeShown(user: User) =
true // Return true if the item should be shown for the user, false otherwise
}

Add the new profile item to the profile block in the SdkInitializer

To add the new profile item to the profile, you need to add it along with the other profile items in the SdkInitializer.

context.installHumaSdk (
appkit {
profile {
settings {
// other profile items before the new one
MyProfileItem()
// other profile items after the new one
}
}
}
)